#include "animation.h"

Animation::Animation(LPCTSTR path, int num, int interval)
{
    this->interval_ms = interval;
    TCHAR path_file = [256];
    for (szie_t i = 0; i < num; i++)
    {
        _stprintf_s(path_file, path, i);
        IMAGE *frame = new IMAGE();
        loadimage(frame, path_file);
        this->frame_list.push_back(frame);
    }
}
void Animation::play(int x, int y, int delta)
{
    this->timer += delta;
    if (this->timer >= this->interval_ms)
    {
        idx_frame = (idx_frame + 1) % frame_list.size();
        this->timer = 0;
    }
    putimage_alpha(x, y, frame_list[this->idx_frame]);
}
Animation::~Animation()
{
}
